USE [BookKeeper]
GO
/****** Object:  ForeignKey [FK_Product2User_Products]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product2User_Products]') AND parent_object_id = OBJECT_ID(N'[dbo].[Product2User]'))
ALTER TABLE [dbo].[Product2User] DROP CONSTRAINT [FK_Product2User_Products]
GO
/****** Object:  ForeignKey [FK_Product2User_User]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Product2User]'))
ALTER TABLE [dbo].[Product2User] DROP CONSTRAINT [FK_Product2User_User]
GO
/****** Object:  ForeignKey [FK_Product2Category_ProductCategories]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product2Category_ProductCategories]') AND parent_object_id = OBJECT_ID(N'[dbo].[Product2Category]'))
ALTER TABLE [dbo].[Product2Category] DROP CONSTRAINT [FK_Product2Category_ProductCategories]
GO
/****** Object:  ForeignKey [FK_Product2Category_Products]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product2Category_Products]') AND parent_object_id = OBJECT_ID(N'[dbo].[Product2Category]'))
ALTER TABLE [dbo].[Product2Category] DROP CONSTRAINT [FK_Product2Category_Products]
GO
/****** Object:  ForeignKey [FK_Category2Category2User_ProductCategories]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category2Category2User_ProductCategories]') AND parent_object_id = OBJECT_ID(N'[dbo].[Category2Category2User]'))
ALTER TABLE [dbo].[Category2Category2User] DROP CONSTRAINT [FK_Category2Category2User_ProductCategories]
GO
/****** Object:  ForeignKey [FK_Category2Category2User_ProductCategories1]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category2Category2User_ProductCategories1]') AND parent_object_id = OBJECT_ID(N'[dbo].[Category2Category2User]'))
ALTER TABLE [dbo].[Category2Category2User] DROP CONSTRAINT [FK_Category2Category2User_ProductCategories1]
GO
/****** Object:  ForeignKey [FK_Category2Category2User_User]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category2Category2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Category2Category2User]'))
ALTER TABLE [dbo].[Category2Category2User] DROP CONSTRAINT [FK_Category2Category2User_User]
GO
/****** Object:  ForeignKey [FK_Accounts_Currencies]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Accounts_Currencies]') AND parent_object_id = OBJECT_ID(N'[dbo].[Accounts]'))
ALTER TABLE [dbo].[Accounts] DROP CONSTRAINT [FK_Accounts_Currencies]
GO
/****** Object:  ForeignKey [FK_Dimension2User_Dimensions]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Dimension2User_Dimensions]') AND parent_object_id = OBJECT_ID(N'[dbo].[Dimension2User]'))
ALTER TABLE [dbo].[Dimension2User] DROP CONSTRAINT [FK_Dimension2User_Dimensions]
GO
/****** Object:  ForeignKey [FK_Dimension2User_User]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Dimension2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Dimension2User]'))
ALTER TABLE [dbo].[Dimension2User] DROP CONSTRAINT [FK_Dimension2User_User]
GO
/****** Object:  ForeignKey [FK_Currency2User_Currencies]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Currency2User_Currencies]') AND parent_object_id = OBJECT_ID(N'[dbo].[Currency2User]'))
ALTER TABLE [dbo].[Currency2User] DROP CONSTRAINT [FK_Currency2User_Currencies]
GO
/****** Object:  ForeignKey [FK_Currency2User_User]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Currency2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Currency2User]'))
ALTER TABLE [dbo].[Currency2User] DROP CONSTRAINT [FK_Currency2User_User]
GO
/****** Object:  ForeignKey [FK_Transactions_Accounts]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Transactions_Accounts]') AND parent_object_id = OBJECT_ID(N'[dbo].[Transactions]'))
ALTER TABLE [dbo].[Transactions] DROP CONSTRAINT [FK_Transactions_Accounts]
GO
/****** Object:  ForeignKey [FK_Transactions_Category2Category2User]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Transactions_Category2Category2User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Transactions]'))
ALTER TABLE [dbo].[Transactions] DROP CONSTRAINT [FK_Transactions_Category2Category2User]
GO
/****** Object:  ForeignKey [FK_Transactions_Products]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Transactions_Products]') AND parent_object_id = OBJECT_ID(N'[dbo].[Transactions]'))
ALTER TABLE [dbo].[Transactions] DROP CONSTRAINT [FK_Transactions_Products]
GO
/****** Object:  ForeignKey [FK_Account2User_Accounts]    Script Date: 10/27/2009 12:08:33 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Account2User_Accounts]') AND parent_object_id = OBJECT_ID(N'[dbo].[Account2User]'))
ALTER TABLE [dbo].[Account2User] DROP CONSTRAINT [FK_Account2User_Accounts]
GO
/****** Object:  ForeignKey [FK_Account2User_User]    Script Date: 10/27/2009 12:08:33 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Account2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Account2User]'))
ALTER TABLE [dbo].[Account2User] DROP CONSTRAINT [FK_Account2User_User]
GO
/****** Object:  Table [dbo].[Account2User]    Script Date: 10/27/2009 12:08:33 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Account2User_Accounts]') AND parent_object_id = OBJECT_ID(N'[dbo].[Account2User]'))
ALTER TABLE [dbo].[Account2User] DROP CONSTRAINT [FK_Account2User_Accounts]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Account2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Account2User]'))
ALTER TABLE [dbo].[Account2User] DROP CONSTRAINT [FK_Account2User_User]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Account2User]') AND type in (N'U'))
DROP TABLE [dbo].[Account2User]
GO
/****** Object:  Table [dbo].[Transactions]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Transactions_Accounts]') AND parent_object_id = OBJECT_ID(N'[dbo].[Transactions]'))
ALTER TABLE [dbo].[Transactions] DROP CONSTRAINT [FK_Transactions_Accounts]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Transactions_Category2Category2User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Transactions]'))
ALTER TABLE [dbo].[Transactions] DROP CONSTRAINT [FK_Transactions_Category2Category2User]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Transactions_Products]') AND parent_object_id = OBJECT_ID(N'[dbo].[Transactions]'))
ALTER TABLE [dbo].[Transactions] DROP CONSTRAINT [FK_Transactions_Products]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Transactions]') AND type in (N'U'))
DROP TABLE [dbo].[Transactions]
GO
/****** Object:  Table [dbo].[Currency2User]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Currency2User_Currencies]') AND parent_object_id = OBJECT_ID(N'[dbo].[Currency2User]'))
ALTER TABLE [dbo].[Currency2User] DROP CONSTRAINT [FK_Currency2User_Currencies]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Currency2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Currency2User]'))
ALTER TABLE [dbo].[Currency2User] DROP CONSTRAINT [FK_Currency2User_User]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Currency2User]') AND type in (N'U'))
DROP TABLE [dbo].[Currency2User]
GO
/****** Object:  Table [dbo].[Dimension2User]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Dimension2User_Dimensions]') AND parent_object_id = OBJECT_ID(N'[dbo].[Dimension2User]'))
ALTER TABLE [dbo].[Dimension2User] DROP CONSTRAINT [FK_Dimension2User_Dimensions]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Dimension2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Dimension2User]'))
ALTER TABLE [dbo].[Dimension2User] DROP CONSTRAINT [FK_Dimension2User_User]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Dimension2User]') AND type in (N'U'))
DROP TABLE [dbo].[Dimension2User]
GO
/****** Object:  Table [dbo].[Accounts]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Accounts_Currencies]') AND parent_object_id = OBJECT_ID(N'[dbo].[Accounts]'))
ALTER TABLE [dbo].[Accounts] DROP CONSTRAINT [FK_Accounts_Currencies]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Accounts]') AND type in (N'U'))
DROP TABLE [dbo].[Accounts]
GO
/****** Object:  Table [dbo].[Category2Category2User]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category2Category2User_ProductCategories]') AND parent_object_id = OBJECT_ID(N'[dbo].[Category2Category2User]'))
ALTER TABLE [dbo].[Category2Category2User] DROP CONSTRAINT [FK_Category2Category2User_ProductCategories]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category2Category2User_ProductCategories1]') AND parent_object_id = OBJECT_ID(N'[dbo].[Category2Category2User]'))
ALTER TABLE [dbo].[Category2Category2User] DROP CONSTRAINT [FK_Category2Category2User_ProductCategories1]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category2Category2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Category2Category2User]'))
ALTER TABLE [dbo].[Category2Category2User] DROP CONSTRAINT [FK_Category2Category2User_User]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Category2Category2User]') AND type in (N'U'))
DROP TABLE [dbo].[Category2Category2User]
GO
/****** Object:  Table [dbo].[Product2Category]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product2Category_ProductCategories]') AND parent_object_id = OBJECT_ID(N'[dbo].[Product2Category]'))
ALTER TABLE [dbo].[Product2Category] DROP CONSTRAINT [FK_Product2Category_ProductCategories]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product2Category_Products]') AND parent_object_id = OBJECT_ID(N'[dbo].[Product2Category]'))
ALTER TABLE [dbo].[Product2Category] DROP CONSTRAINT [FK_Product2Category_Products]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Product2Category]') AND type in (N'U'))
DROP TABLE [dbo].[Product2Category]
GO
/****** Object:  Table [dbo].[Product2User]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product2User_Products]') AND parent_object_id = OBJECT_ID(N'[dbo].[Product2User]'))
ALTER TABLE [dbo].[Product2User] DROP CONSTRAINT [FK_Product2User_Products]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Product2User]'))
ALTER TABLE [dbo].[Product2User] DROP CONSTRAINT [FK_Product2User_User]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Product2User]') AND type in (N'U'))
DROP TABLE [dbo].[Product2User]
GO
/****** Object:  Table [dbo].[ProductCategories]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ProductCategories]') AND type in (N'U'))
DROP TABLE [dbo].[ProductCategories]
GO
/****** Object:  Table [dbo].[Products]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Products]') AND type in (N'U'))
DROP TABLE [dbo].[Products]
GO
/****** Object:  Table [dbo].[Right]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Right]') AND type in (N'U'))
DROP TABLE [dbo].[Right]
GO
/****** Object:  Table [dbo].[Currencies]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Currencies]') AND type in (N'U'))
DROP TABLE [dbo].[Currencies]
GO
/****** Object:  Table [dbo].[Dimensions]    Script Date: 10/27/2009 12:08:32 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Dimensions]') AND type in (N'U'))
DROP TABLE [dbo].[Dimensions]
GO
/****** Object:  Table [dbo].[User]    Script Date: 10/27/2009 12:08:31 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[User]') AND type in (N'U'))
DROP TABLE [dbo].[User]
GO
/****** Object:  Table [dbo].[User]    Script Date: 10/27/2009 12:08:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[User]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[User](
	[Id] [int] NOT NULL,
	[Login] [nvarchar](50) NOT NULL,
	[Password] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Dimensions]    Script Date: 10/27/2009 12:08:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Dimensions]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Dimensions](
	[Id] [int] NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_Dimensions] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Dimensions]') AND name = N'IX_Dimensions')
CREATE UNIQUE NONCLUSTERED INDEX [IX_Dimensions] ON [dbo].[Dimensions] 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Currencies]    Script Date: 10/27/2009 12:08:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Currencies]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Currencies](
	[Id] [int] NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_Currencies] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Right]    Script Date: 10/27/2009 12:08:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Right]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Right](
	[Id] [int] NOT NULL,
	[Name] [nvarchar](50) NOT NULL
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Products]    Script Date: 10/27/2009 12:08:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Products]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Products](
	[Id] [int] NOT NULL,
 CONSTRAINT [PK_Products] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[ProductCategories]    Script Date: 10/27/2009 12:08:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ProductCategories]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ProductCategories](
	[Id] [int] NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_ProductCategories] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Product2User]    Script Date: 10/27/2009 12:08:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Product2User]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Product2User](
	[ProductId] [int] NOT NULL,
	[UserId] [int] NOT NULL,
 CONSTRAINT [PK_Product2User] PRIMARY KEY CLUSTERED 
(
	[ProductId] ASC,
	[UserId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Product2Category]    Script Date: 10/27/2009 12:08:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Product2Category]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Product2Category](
	[ProductId] [int] NULL,
	[CategoryId] [int] NULL
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Category2Category2User]    Script Date: 10/27/2009 12:08:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Category2Category2User]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Category2Category2User](
	[ProductCategoryId] [int] NOT NULL,
	[ParentProductCategoryId] [int] NULL,
	[UserId] [int] NOT NULL,
	[Id] [int] NOT NULL,
 CONSTRAINT [PK_Category2Category2User] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[Category2Category2User]') AND name = N'IX_Category2Category2User')
CREATE UNIQUE NONCLUSTERED INDEX [IX_Category2Category2User] ON [dbo].[Category2Category2User] 
(
	[ParentProductCategoryId] ASC,
	[ProductCategoryId] ASC,
	[UserId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Accounts]    Script Date: 10/27/2009 12:08:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Accounts]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Accounts](
	[Id] [int] NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
	[CurrencyId] [int] NOT NULL,
	[CreatedOn] [datetime] NOT NULL,
 CONSTRAINT [PK_Accounts] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Dimension2User]    Script Date: 10/27/2009 12:08:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Dimension2User]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Dimension2User](
	[DimensionId] [int] NOT NULL,
	[UserId] [int] NOT NULL,
 CONSTRAINT [PK_Dimension2User] PRIMARY KEY CLUSTERED 
(
	[DimensionId] ASC,
	[UserId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Currency2User]    Script Date: 10/27/2009 12:08:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Currency2User]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Currency2User](
	[CurrencyId] [int] NOT NULL,
	[UserId] [int] NOT NULL,
 CONSTRAINT [PK_Currency2User] PRIMARY KEY CLUSTERED 
(
	[CurrencyId] ASC,
	[UserId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Transactions]    Script Date: 10/27/2009 12:08:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Transactions]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Transactions](
	[Id] [int] NOT NULL,
	[AccountId] [int] NOT NULL,
	[CreatedOn] [datetime] NOT NULL,
	[ProductId] [int] NOT NULL,
	[Category2Category2UserId] [int] NOT NULL,
 CONSTRAINT [PK_Transactions] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[Account2User]    Script Date: 10/27/2009 12:08:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Account2User]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Account2User](
	[AccountId] [int] NOT NULL,
	[UserId] [int] NOT NULL,
 CONSTRAINT [PK_Account2User] PRIMARY KEY CLUSTERED 
(
	[AccountId] ASC,
	[UserId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  ForeignKey [FK_Product2User_Products]    Script Date: 10/27/2009 12:08:32 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product2User_Products]') AND parent_object_id = OBJECT_ID(N'[dbo].[Product2User]'))
ALTER TABLE [dbo].[Product2User]  WITH CHECK ADD  CONSTRAINT [FK_Product2User_Products] FOREIGN KEY([ProductId])
REFERENCES [dbo].[Products] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product2User_Products]') AND parent_object_id = OBJECT_ID(N'[dbo].[Product2User]'))
ALTER TABLE [dbo].[Product2User] CHECK CONSTRAINT [FK_Product2User_Products]
GO
/****** Object:  ForeignKey [FK_Product2User_User]    Script Date: 10/27/2009 12:08:32 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Product2User]'))
ALTER TABLE [dbo].[Product2User]  WITH CHECK ADD  CONSTRAINT [FK_Product2User_User] FOREIGN KEY([UserId])
REFERENCES [dbo].[User] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Product2User]'))
ALTER TABLE [dbo].[Product2User] CHECK CONSTRAINT [FK_Product2User_User]
GO
/****** Object:  ForeignKey [FK_Product2Category_ProductCategories]    Script Date: 10/27/2009 12:08:32 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product2Category_ProductCategories]') AND parent_object_id = OBJECT_ID(N'[dbo].[Product2Category]'))
ALTER TABLE [dbo].[Product2Category]  WITH CHECK ADD  CONSTRAINT [FK_Product2Category_ProductCategories] FOREIGN KEY([CategoryId])
REFERENCES [dbo].[ProductCategories] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product2Category_ProductCategories]') AND parent_object_id = OBJECT_ID(N'[dbo].[Product2Category]'))
ALTER TABLE [dbo].[Product2Category] CHECK CONSTRAINT [FK_Product2Category_ProductCategories]
GO
/****** Object:  ForeignKey [FK_Product2Category_Products]    Script Date: 10/27/2009 12:08:32 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product2Category_Products]') AND parent_object_id = OBJECT_ID(N'[dbo].[Product2Category]'))
ALTER TABLE [dbo].[Product2Category]  WITH CHECK ADD  CONSTRAINT [FK_Product2Category_Products] FOREIGN KEY([ProductId])
REFERENCES [dbo].[Products] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product2Category_Products]') AND parent_object_id = OBJECT_ID(N'[dbo].[Product2Category]'))
ALTER TABLE [dbo].[Product2Category] CHECK CONSTRAINT [FK_Product2Category_Products]
GO
/****** Object:  ForeignKey [FK_Category2Category2User_ProductCategories]    Script Date: 10/27/2009 12:08:32 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category2Category2User_ProductCategories]') AND parent_object_id = OBJECT_ID(N'[dbo].[Category2Category2User]'))
ALTER TABLE [dbo].[Category2Category2User]  WITH CHECK ADD  CONSTRAINT [FK_Category2Category2User_ProductCategories] FOREIGN KEY([ProductCategoryId])
REFERENCES [dbo].[ProductCategories] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category2Category2User_ProductCategories]') AND parent_object_id = OBJECT_ID(N'[dbo].[Category2Category2User]'))
ALTER TABLE [dbo].[Category2Category2User] CHECK CONSTRAINT [FK_Category2Category2User_ProductCategories]
GO
/****** Object:  ForeignKey [FK_Category2Category2User_ProductCategories1]    Script Date: 10/27/2009 12:08:32 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category2Category2User_ProductCategories1]') AND parent_object_id = OBJECT_ID(N'[dbo].[Category2Category2User]'))
ALTER TABLE [dbo].[Category2Category2User]  WITH CHECK ADD  CONSTRAINT [FK_Category2Category2User_ProductCategories1] FOREIGN KEY([ParentProductCategoryId])
REFERENCES [dbo].[ProductCategories] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category2Category2User_ProductCategories1]') AND parent_object_id = OBJECT_ID(N'[dbo].[Category2Category2User]'))
ALTER TABLE [dbo].[Category2Category2User] CHECK CONSTRAINT [FK_Category2Category2User_ProductCategories1]
GO
/****** Object:  ForeignKey [FK_Category2Category2User_User]    Script Date: 10/27/2009 12:08:32 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category2Category2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Category2Category2User]'))
ALTER TABLE [dbo].[Category2Category2User]  WITH CHECK ADD  CONSTRAINT [FK_Category2Category2User_User] FOREIGN KEY([UserId])
REFERENCES [dbo].[User] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category2Category2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Category2Category2User]'))
ALTER TABLE [dbo].[Category2Category2User] CHECK CONSTRAINT [FK_Category2Category2User_User]
GO
/****** Object:  ForeignKey [FK_Accounts_Currencies]    Script Date: 10/27/2009 12:08:32 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Accounts_Currencies]') AND parent_object_id = OBJECT_ID(N'[dbo].[Accounts]'))
ALTER TABLE [dbo].[Accounts]  WITH CHECK ADD  CONSTRAINT [FK_Accounts_Currencies] FOREIGN KEY([CurrencyId])
REFERENCES [dbo].[Currencies] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Accounts_Currencies]') AND parent_object_id = OBJECT_ID(N'[dbo].[Accounts]'))
ALTER TABLE [dbo].[Accounts] CHECK CONSTRAINT [FK_Accounts_Currencies]
GO
/****** Object:  ForeignKey [FK_Dimension2User_Dimensions]    Script Date: 10/27/2009 12:08:32 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Dimension2User_Dimensions]') AND parent_object_id = OBJECT_ID(N'[dbo].[Dimension2User]'))
ALTER TABLE [dbo].[Dimension2User]  WITH CHECK ADD  CONSTRAINT [FK_Dimension2User_Dimensions] FOREIGN KEY([DimensionId])
REFERENCES [dbo].[Dimensions] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Dimension2User_Dimensions]') AND parent_object_id = OBJECT_ID(N'[dbo].[Dimension2User]'))
ALTER TABLE [dbo].[Dimension2User] CHECK CONSTRAINT [FK_Dimension2User_Dimensions]
GO
/****** Object:  ForeignKey [FK_Dimension2User_User]    Script Date: 10/27/2009 12:08:32 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Dimension2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Dimension2User]'))
ALTER TABLE [dbo].[Dimension2User]  WITH CHECK ADD  CONSTRAINT [FK_Dimension2User_User] FOREIGN KEY([UserId])
REFERENCES [dbo].[User] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Dimension2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Dimension2User]'))
ALTER TABLE [dbo].[Dimension2User] CHECK CONSTRAINT [FK_Dimension2User_User]
GO
/****** Object:  ForeignKey [FK_Currency2User_Currencies]    Script Date: 10/27/2009 12:08:32 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Currency2User_Currencies]') AND parent_object_id = OBJECT_ID(N'[dbo].[Currency2User]'))
ALTER TABLE [dbo].[Currency2User]  WITH CHECK ADD  CONSTRAINT [FK_Currency2User_Currencies] FOREIGN KEY([CurrencyId])
REFERENCES [dbo].[Currencies] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Currency2User_Currencies]') AND parent_object_id = OBJECT_ID(N'[dbo].[Currency2User]'))
ALTER TABLE [dbo].[Currency2User] CHECK CONSTRAINT [FK_Currency2User_Currencies]
GO
/****** Object:  ForeignKey [FK_Currency2User_User]    Script Date: 10/27/2009 12:08:32 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Currency2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Currency2User]'))
ALTER TABLE [dbo].[Currency2User]  WITH CHECK ADD  CONSTRAINT [FK_Currency2User_User] FOREIGN KEY([UserId])
REFERENCES [dbo].[User] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Currency2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Currency2User]'))
ALTER TABLE [dbo].[Currency2User] CHECK CONSTRAINT [FK_Currency2User_User]
GO
/****** Object:  ForeignKey [FK_Transactions_Accounts]    Script Date: 10/27/2009 12:08:32 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Transactions_Accounts]') AND parent_object_id = OBJECT_ID(N'[dbo].[Transactions]'))
ALTER TABLE [dbo].[Transactions]  WITH CHECK ADD  CONSTRAINT [FK_Transactions_Accounts] FOREIGN KEY([AccountId])
REFERENCES [dbo].[Accounts] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Transactions_Accounts]') AND parent_object_id = OBJECT_ID(N'[dbo].[Transactions]'))
ALTER TABLE [dbo].[Transactions] CHECK CONSTRAINT [FK_Transactions_Accounts]
GO
/****** Object:  ForeignKey [FK_Transactions_Category2Category2User]    Script Date: 10/27/2009 12:08:32 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Transactions_Category2Category2User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Transactions]'))
ALTER TABLE [dbo].[Transactions]  WITH CHECK ADD  CONSTRAINT [FK_Transactions_Category2Category2User] FOREIGN KEY([Category2Category2UserId])
REFERENCES [dbo].[Category2Category2User] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Transactions_Category2Category2User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Transactions]'))
ALTER TABLE [dbo].[Transactions] CHECK CONSTRAINT [FK_Transactions_Category2Category2User]
GO
/****** Object:  ForeignKey [FK_Transactions_Products]    Script Date: 10/27/2009 12:08:32 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Transactions_Products]') AND parent_object_id = OBJECT_ID(N'[dbo].[Transactions]'))
ALTER TABLE [dbo].[Transactions]  WITH CHECK ADD  CONSTRAINT [FK_Transactions_Products] FOREIGN KEY([ProductId])
REFERENCES [dbo].[Products] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Transactions_Products]') AND parent_object_id = OBJECT_ID(N'[dbo].[Transactions]'))
ALTER TABLE [dbo].[Transactions] CHECK CONSTRAINT [FK_Transactions_Products]
GO
/****** Object:  ForeignKey [FK_Account2User_Accounts]    Script Date: 10/27/2009 12:08:33 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Account2User_Accounts]') AND parent_object_id = OBJECT_ID(N'[dbo].[Account2User]'))
ALTER TABLE [dbo].[Account2User]  WITH CHECK ADD  CONSTRAINT [FK_Account2User_Accounts] FOREIGN KEY([AccountId])
REFERENCES [dbo].[Accounts] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Account2User_Accounts]') AND parent_object_id = OBJECT_ID(N'[dbo].[Account2User]'))
ALTER TABLE [dbo].[Account2User] CHECK CONSTRAINT [FK_Account2User_Accounts]
GO
/****** Object:  ForeignKey [FK_Account2User_User]    Script Date: 10/27/2009 12:08:33 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Account2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Account2User]'))
ALTER TABLE [dbo].[Account2User]  WITH CHECK ADD  CONSTRAINT [FK_Account2User_User] FOREIGN KEY([UserId])
REFERENCES [dbo].[User] ([Id])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Account2User_User]') AND parent_object_id = OBJECT_ID(N'[dbo].[Account2User]'))
ALTER TABLE [dbo].[Account2User] CHECK CONSTRAINT [FK_Account2User_User]
GO
